<template>
    <a-modal class="my-modal short" v-model="modal_show" title="分配" @ok="modelok" @cancel="modelcancel" width="400px" :maskClosable="false" :centered="true">
        <div class="body-content">
            <div v-show="type=='select'">
                <a-row>
                    <span  v-show="values.length>1">已选择了{{values.length}}个图斑.将分配给</span>
                    <span  v-show="values.length==1">已选择了编号{{values.length==1?values[0].jvbh:""}}的图斑.将分配给</span>
                </a-row>
                 <a-row>
                    <label>实施人员：</label>
                    <a-select style="width: 120px"  allowClear v-model="user">
                        <a-select-option :value="item.fullname" v-for="(item,index) in activeUsers" :key="index">{{item.fullname}}</a-select-option>
                    </a-select>
                </a-row>
            </div>
            <div v-show="type=='input'">
                <a-row>
                    <a-space>从
                        <a-input placeholder="数字" v-model="num_from" allowClear/>
                        到
                        <a-input placeholder="数字" v-model="num_to" allowClear/>
                    </a-space>
                </a-row>
                <a-row>
                    <label>将分配给实施人员：</label>
                    <a-select style="width: 120px"  allowClear v-model="user">
                        <a-select-option :value="item.fullname" v-for="(item,index) in activeUsers" :key="index">{{item.fullname}}</a-select-option>
                    </a-select>
                </a-row>
            </div>
        </div>
    </a-modal>
</template>
<script>
export default {
    components: {},
    data() {
        return {
            modal_show: false,
            type:"select",
            values:[],

            num_from:0,
            num_to:0,
            activeUsers:[],
            user:"",
            
        };
    },
    mounted() {
        this.$mitt.$off('fenpei_to_user').$on('fenpei_to_user', _options => {
            this.type=_options.type
            this.values=_options.values||[]
            this.activeUsers=_options.activeUsers||[]
            this.modal_show = true;
        });
    },
    methods: {
        modelcancel(){
            this.modal_show = false;
        },
        task_status_change(){
            
        },
        modelok() {
             if(!this.user){
                this.$message.info('没有选择分配给谁呢');
                return false
            }
            if(this.type=="input"){
                this.num_from=this.num_from-0
                this.num_to=this.num_to-0
                if(this.num_from>0 && this.num_to>0 &&this.num_from <=this.num_to){
                }
                else{
                    this.$message.info('必须是数字,并且第一个应不大于第二个数字');
                    return false
                }
            }
            this.$mitt.emit("fenpei_to_user_back",{
                type:this.type,
                values:this.values,
                num_from:this.num_from,
                num_to:this.num_to,
                user:this.user,
            })
            this.modal_show = false;
        },
    },
};
</script>
<style></style>
